package com.exchange.web.interfaces.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.exchange.common.annotation.Log;
import com.exchange.common.enums.BusinessType;
import com.exchange.interfaces.domain.ExcLinkAccount;
import com.exchange.interfaces.service.IExcLinkAccountService;
import com.exchange.common.core.controller.BaseController;
import com.exchange.common.core.page.TableDataInfo;
import com.exchange.common.core.domain.AjaxResult;
import com.exchange.common.utils.poi.ExcelUtil;

/**
 * 交换平台_链接账号 信息操作处理
 * 
 * @author exchange
 * @date 2019-06-03
 */
@Controller
@RequestMapping("/interfaces/excLinkAccount")
public class ExcLinkAccountController extends BaseController
{
    private String prefix = "interfaces/excLinkAccount";
	
	@Autowired
	private IExcLinkAccountService excLinkAccountService;
	
	@RequiresPermissions("interfaces:excLinkAccount:view")
	@GetMapping()
	public String excLinkAccount()
	{
	    return prefix + "/excLinkAccount";
	}
	
	/**
	 * 查询交换平台_链接账号列表
	 */
	@RequiresPermissions("interfaces:excLinkAccount:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(ExcLinkAccount excLinkAccount)
	{
		startPage();
        List<ExcLinkAccount> list = excLinkAccountService.selectExcLinkAccountList(excLinkAccount);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出交换平台_链接账号列表
	 */
	@RequiresPermissions("interfaces:excLinkAccount:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ExcLinkAccount excLinkAccount)
    {
    	List<ExcLinkAccount> list = excLinkAccountService.selectExcLinkAccountList(excLinkAccount);
        ExcelUtil<ExcLinkAccount> util = new ExcelUtil<ExcLinkAccount>(ExcLinkAccount.class);
        return util.exportExcel(list, "excLinkAccount");
    }
	
	/**
	 * 新增交换平台_链接账号
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存交换平台_链接账号
	 */
	@RequiresPermissions("interfaces:excLinkAccount:add")
	@Log(title = "交换平台_链接账号", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ExcLinkAccount excLinkAccount)
	{		
		return toAjax(excLinkAccountService.insertExcLinkAccount(excLinkAccount));
	}

	/**
	 * 修改交换平台_链接账号
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		ExcLinkAccount excLinkAccount = excLinkAccountService.selectExcLinkAccountById(id);
		mmap.put("excLinkAccount", excLinkAccount);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存交换平台_链接账号
	 */
	@RequiresPermissions("interfaces:excLinkAccount:edit")
	@Log(title = "交换平台_链接账号", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ExcLinkAccount excLinkAccount)
	{		
		return toAjax(excLinkAccountService.updateExcLinkAccount(excLinkAccount));
	}
	
	/**
	 * 删除交换平台_链接账号
	 */
	@RequiresPermissions("interfaces:excLinkAccount:remove")
	@Log(title = "交换平台_链接账号", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(excLinkAccountService.deleteExcLinkAccountByIds(ids));
	}
	
}
